<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
//use kartik\file\FileInput;
use kartik\widgets\FileInput;
/* @var $this yii\web\View */
/* @var $model common\models\business\NewBusinessInspection */
/* @var $form yii\widgets\ActiveForm */
?>
<style>
    .file-input{
        width: 70%;
        margin-left: 120px;
    }
</style>

<div class="row">
    <div class="col-lg-12">
        <section class="panel">
        <div class="panel-body">
            <div class="adv-table editable-table ">
                <div class="new-business-inspection-form">



                    <?php $form = ActiveForm::begin([
                        'options' => ['class' => 'form-horizontal','enctype' => 'multipart/form-data'],
                        'fieldConfig' => [
                            'template' => "<div class='col-xs-3 col-sm-2 text-right'>{label}</div><div class='col-xs-9 col-sm-7'>{input}</div><div class='col-xs-12 col-xs-offset-3 col-sm-3 col-sm-offset-0'>{error}</div>",
                        ]
                    ]); ?>


                        <?= $form->field($model, 'business_person')->textInput(['maxlength' => true,'readonly'=>true]) ?>

                        <?= $form->field($model, 'lat')->textInput(['maxlength' => true,'readonly'=>true]) ?>

                        <?= $form->field($model, 'lng')->textInput(['maxlength' => true,'readonly'=>true]) ?>

                        <?= $form->field($model, 'address')->textInput(['maxlength' => true,'readonly'=>true]) ?>

                        <?= $form->field($model, 'status')->dropDownList(\common\models\business\NewBusinessInspection::$statues) ?>

                        <?= $form->field($model, 'remark')->textarea(['maxlength' => true]) ?>

                        <?php $arr = array_chunk($simpledata,3,true);
                        foreach ($arr as $key => $value){ ?>
                            <div class="form-group" style="margin-left:70px">
                                <?php foreach ($value as $key => $row){ ?>
                                    <?php if($row['fieldtype'] == 'input' || $row['fieldtype'] == 'select'  || $row['fieldtype'] == 'textarea') { ?>
                                        <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"><?= $row['fieldname'] ?></label>
                                        <div class="col-sm-2 col-xs-4">
                                            <input class="form-control" name="<?= $row['fieldname'] ?>" type="text" value="<?= $row['val'] ?>" placeholder="<?= $row['fieldname'] ?>">
                                        </div>
                                    <?php } ?>
                                <?php } ?>
                            </div>
                        <?php } ?>

                        <?php foreach ($imgdata as $key => $row){ ?>
                             <div class="form-group" style="margin-left:60px">
                            <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label"><?= $row['fieldname'] ?></label>

                            <?= FileInput::widget([
                                'model' => $model->data,
                                'name' => $row['fieldname'].'[]',
                                'options' => ['multiple' => true],
                                'pluginOptions' => [
                                    // 需要预览的文件格式
                                    'previewFileType' => 'image',
                                    // 预览的文件
                                    'initialPreview' => \common\components\Upload::checkGetUrl($row->val,true,'val'),
                                    // 需要展示的图片设置，比如图片的宽度等
                                    'initialPreviewConfig' => \common\components\Upload::initialPreviewConfig($row,'val',\common\models\business\NewBusinessInspectionData::tableName(),$row['id']),
                                    // 是否展示预览图
                                    'initialPreviewAsData' => true,
                                    'overwriteInitial' => false,
                                    'showUpload' => false,
                                ],
                            ]); ?>
                             </div>
                        <?php } ?>


                    <div class="form-group">
                        <?= Html::submitButton($model->isNewRecord ? '确认提交' : '确认更新', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
                    </div>
                    <?php ActiveForm::end(); ?>
                </div>
            </div>
        </div>
    </section>
</div>
</div>